package ele.controller;

import app.nbdevices.modle.revModle.DataChangedModle;
import app.nbdevices.modle.revModle.ServiceModle;
import ele.dto.SumDto;
import ele.modle.revModle.RevEleReportData;
import ele.service.IEleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import water.dto.DataDto;

import java.util.List;

/**
 * 这是一个二级控制器，用来处理电表设备上传的数据
 */

@Component
public class EleController {
    @Autowired
    @Qualifier("EleService")
    IEleService svcEle;

    public void eleReportData(DataChangedModle dataChanged){
        ServiceModle service = dataChanged.getService();
        RevEleReportData revEleReportData=service.getData()
                .toJavaObject(RevEleReportData.class);
        svcEle.saveEleCycleData(revEleReportData,dataChanged.getDeviceId());
    }

    public List<DataDto> getWaterData(int t, String internetDevId){
        return svcEle.getELeDataByTime(t,internetDevId);
    }

    public List<SumDto> getSumEle(){
         return svcEle.getEleSum();
    }

}
